package cn.smbms.dao.impl;

import cn.smbms.beans.User;
import cn.smbms.dao.UserDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
@Repository("userDao")
public class UserDaoImpl implements UserDao {
     //负责管理MyBatis的SqlSession，调用SQL映射语句，实现对数据库的访问
    @Autowired
     private  SqlSessionTemplate  sqlSessionTemplate ;
    @Override
    public List<User> getUserList(User user) {
        List<User> selectList = sqlSessionTemplate.selectList("cn.smbms.dao.UserDao.getUserList", user);
        return selectList;
    }

    @Override
    public void addUser(User user) {
       sqlSessionTemplate.insert("cn.smbms.dao.UserDao.addUser",user);
    }

    @Override
    public void deleteUser(User user) {
        sqlSessionTemplate.delete("cn.smbms.dao.UserDao.deleteUser",user);
    }

    @Override
    public void updateUser(User user) {
        sqlSessionTemplate.update("cn.smbms.dao.UserDao.updateUser",user);
    }
}
